<template>
  <view style="width: 100%; height: 100%">
    <image :src="imageUrl" style="width: 100%; height: 100%"></image>
  </view>
</template>

<script>
import * as QR from "@/static/js/qrcode";
import { drawMyQrcode } from "@/utils/util.js";

export default {
  data() {
    return {
      imageUrl: "",
    };
  },
  props: {
    // 名字标识
    flagname: {
      type: String,
      value: "",
    },
    houseName: {
      type: String,
      value: "",
    },
    communityId: {
      type: String,
      value: "",
    },
    visitorPhone: {
      type: String,
      value: "",
    },
    qrCodeVersion: {
      type: String,
      value: "",
    },
    code: {
      type: Array,
      value: [],
    },
    isVisitor: {
      type: Boolean,
      value: false,
    },
    unitnos: {
      type: Array,
      value: [],
    },
    communityId: {
      type: String,
      value: "",
    },
    interviewPhone: {
      type: String,
      value: "",
    },
    openPhone: {
      type: String,
      value: "",
    },
    time: {
      type: String,
      value: "",
    },
    idqrcode: {
      type: String,
      value: "",
    },
    startTime: {
      type: String,
      value: "",
    },
    endTime: {
      type: String,
      value: "",
    },
    argumentall: {
      type: Object,
      value: {},
    },
  },
  mounted() {
    this.drawQrcode();
  },
  methods: {
    // 小程序二维码生成函数
    drawQrcode() {
      let src;
      src = drawMyQrcode(this.argumentall);
      this.imageUrl = src;
    },
    doorQrcode() {
      let obj = Object.assign(
        {},
        {
          openPhone: this.openPhone,
          communityId: this.communityId,
          time: this.time,
          code: this.code,
          interviewPhone: this.interviewPhone,
        }
      );
      let message = JSON.stringify(obj);
      // 不加密
      let tex = message;
      let text = "&" + tex + "#";
      var imgData = QR.drawImg(text, {
        typeNumber: 4,
        errorCorrectLevel: "H",
        size: 500,
      });

      this.imageUrl = imgData;
    },
    refresh() {
      this.drawQrcode();
    },
  },
};
</script>

<style lang="scss" scoped>
</style>